package com.miyake.dsp.osa.realinstrument;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class Common {
	interface SettingListener {
		void onSet(String value);
	};
	public static Component createSetting(String string, String defaultValue, final SettingListener actionListener) {
		JPanel panel = new JPanel();
		panel.add(new JLabel(string));
		final JTextField text = new JTextField(defaultValue);
		text.setPreferredSize(new Dimension(200, 24));
		panel.add(text);
		
		JButton button = new JButton("Set");
		button.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent arg0) {
				actionListener.onSet(text.getText());
			}
		});
		panel.add(button);
		return panel;
	}
}
